package eu.fishcode.android.ui;

import java.awt.BorderLayout;
import java.awt.Desktop;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URI;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import eu.fishcode.android.ui.component.Dialog;
import eu.fishcode.android.utils.Utils;

class AboutDialog extends Dialog {

	public AboutDialog() {
		super();
		this.setTitle(Utils.getLabel("about.title"));
		this.setDescription(Utils.getLabel("about.description"));
		this.setIcon(Utils.getIcon("about.png"));

		final JLabel text = new JLabel("<html><body>"
				+ "Android Boot Animation Editor<br>" + "Version: Beta 1.0<br>"
				+ "(c) Copyright <a href=\"http:\\fishcode.eu\">fishcode.eu</a><br>"
				+ "<ul><li>Developed by: Cyborg85 from fishcode.eu</li>"
				+ "<li>Tested by: - </li>"
				+ "<li>Language Italian: Cyborg85</li>"
				+ "<li>Language English: Cyborg85</li></ul></body></html>");

		final JButton visit = new JButton(Utils.getLabel("about.visit"));
		visit.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent event) {
				final Desktop desktop = Desktop.isDesktopSupported() ? Desktop
						.getDesktop() : null;
				if ((desktop != null)
						&& desktop.isSupported(Desktop.Action.BROWSE)) {
					try {
						desktop.browse(new URI("http://android.fishcode.eu"));
						AboutDialog.this.dispose();
					} catch (final Exception e) {
						e.printStackTrace();
					}
				}
			}
		});

		final JPanel panelCenter = new JPanel();
		panelCenter.setLayout(new FlowLayout(FlowLayout.LEFT));
		panelCenter.add(text);

		this.footer.add(visit, BorderLayout.LINE_START);

		this.add(panelCenter, BorderLayout.CENTER);

	}

}